/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Minh Duong
 */
@Entity
@Table(name = "Tickets", catalog = "EasyTickets", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Tickets.findAll", query = "SELECT t FROM Tickets t"),
    @NamedQuery(name = "Tickets.findByTicketsId", query = "SELECT t FROM Tickets t WHERE t.ticketsId = :ticketsId"),
    @NamedQuery(name = "Tickets.findByQuantity", query = "SELECT t FROM Tickets t WHERE t.quantity = :quantity"),
    @NamedQuery(name = "Tickets.findByStatus", query = "SELECT t FROM Tickets t WHERE t.status = :status")})
public class Tickets implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "TicketsId", nullable = false)
    private Integer ticketsId;
    @Column(name = "Quantity")
    private Integer quantity;
    @Column(name = "Status")
    private Boolean status;
    @JoinTable(name = "EventTime", joinColumns = {
        @JoinColumn(name = "TicketsId", referencedColumnName = "TicketsId", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "TsID", referencedColumnName = "TsID", nullable = false)})
    @ManyToMany
    private List<TimeSet> timeSetList;
    @JoinColumn(name = "TcID", referencedColumnName = "TcID")
    @ManyToOne
    private TicketsCategory ticketsCategory;
    @JoinColumn(name = "EventId", referencedColumnName = "EventId")
    @ManyToOne
    private Event event;

    public Tickets() {
    }

    public Tickets(Integer ticketsId) {
        this.ticketsId = ticketsId;
    }

    public Integer getTicketsId() {
        return ticketsId;
    }

    public void setTicketsId(Integer ticketsId) {
        this.ticketsId = ticketsId;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public List<TimeSet> getTimeSetList() {
        return timeSetList;
    }

    public void setTimeSetList(List<TimeSet> timeSetList) {
        this.timeSetList = timeSetList;
    }

    public TicketsCategory getTicketsCategory() {
        return ticketsCategory;
    }

    public void setTicketsCategory(TicketsCategory ticketsCategory) {
        this.ticketsCategory = ticketsCategory;
    }

    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ticketsId != null ? ticketsId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tickets)) {
            return false;
        }
        Tickets other = (Tickets) object;
        if ((this.ticketsId == null && other.ticketsId != null) || (this.ticketsId != null && !this.ticketsId.equals(other.ticketsId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Tickets[ticketsId=" + ticketsId + "]";
    }
}
